Skip to content

Visualizer: a statement call of your own function ends as None - #59

Merged
cedricvogel-leo merged 1 commit into
mainfrom
feature/none-of-own-calls
Nov 8, 2026
Merged

cedricvogel-leo merged 1 commit into
mainfrom
feature/none-of-own-calls

Conversation

@cedricvogel-leo

Copy link
Copy Markdown
Collaborator

P49. Until now, a call that is a whole statement and returns None kept its call text as its last step. That hid what a function without a matching return gives.

Rule (_eval_call, _glpython_is_own_function in src/runtime/visualizer.py), the same for a line of the program, a REPL input and a doctest example:

  • The learner's own function → None. That means a _GlpythonFunction (a def or lambda the visualizer traces), or a function whose code comes from a project file (/<path>), from code the visualizer compiled itself (<glpython>, e.g. methods of a class), or from an earlier REPL input (<repl>). This also covers functions of the project's other files, which stay opaque in a REPL or doctest trace.
  • Everything else keeps its call text: built-ins, methods of built-in types, and functions from modules that come with Python or glpython (print(...), xs.append(1), random.shuffle(xs), gturtle.forward(10)).
  • Calls whose value is used show None as before. The console is unchanged: nothing for None, as in CPython's REPL.

Example: anwenden('*', 3, 4) without a case for '*':

  • Test run: the failing example's last step is None, with «Erhalten: (Keine Ausgabe) · Erwartet: 12» below it.
  • Shell and program line: they end on None.
  • «Baum»: the node becomes None, as for a call whose value is used.

Checks:

  • scripts/check-runtime-none-calls.py (new, in test:runtime), which fails on the old code:
    • a program with an own function, a function of another file, a lambda, a method of the learner's class, a function under another name, print, append, random.shuffle, gturtle;
    • a REPL input and a doctest example (traced against the REPL's and the Tests run's namespace): own function with and without print, a function from an earlier REPL input, print, a value;
    • the console prints nothing for None.
  • check-console-browser.mjs, for each of Kasten, Ersetzung and Baum, in Chrome with Pyodide:
    • a line of the program ends as None, while print/append keep their text;
    • a REPL input ends as None and the console shows nothing;
    • the failing example ends as None with «Erhalten» below it.
  • The print-instead-of-return hint and passing examples: doctests.py is untouched, and check-runtime-doctests.py passes.
  • README (a paragraph under the visualizer) and CLAUDE.md updated; the code comments rewritten.

Going live:

  • Merging deploys the embed to Pages, so the courses get it right away (no macro change).
  • For the IDE: tag v0.1.33, then bump the IDE.

🤖 Generated with Claude Code

A call that is a whole statement (a line of the program, a REPL input, a
doctest example) now shows its None as the last step when the callee is the
learner's own function: a def or lambda of the project's files or a library
loaded with it, a method of their class, a function from an earlier REPL
input. Built-ins, methods of built-in types and functions of modules that
come with Python or glpython (print, xs.append, random, gturtle) keep their
call text. The console is unchanged: nothing for None, as CPython's REPL.

Checks: scripts/check-runtime-none-calls.py (in test:runtime) and a browser
case in check-console-browser.mjs for Kasten, Ersetzung and Baum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cedricvogel-leo
cedricvogel-leo merged commit d2d7132 into main Nov 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant